

package taller;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author 19145988-1
 */
public class conectar {
   static String bd = "taller"; 
   static String login = "taller"; 
   static String password = "taller"; 
   static String url = "jdbc:derby://localhost:1527/"+bd; 
 
   Connection conn = null; 
    
   public conectar() { 
      try{          
         Class.forName("org.apache.derby.jdbc.ClientDriver");
         conn = DriverManager.getConnection(url,login,password);
         if(conn!=null){
//             JOptionPane.showMessageDialog(null,"Se ha conectado exitosamente a la base de datos"+bd);
         }
      }catch(SQLException e){ 
        JOptionPane.showMessageDialog(null,e); 
      }catch(ClassNotFoundException e){ 
        JOptionPane.showMessageDialog(null,e); 
      } 
   } 
    
   public Connection getConnection(){ 
      return conn; 
   } 
 
   public void desconectar(){ 
      conn = null; 
   }
   
    
}
